/**
 * This file is part of RailEGo
 * Copyright (c) 2023 Guo Tingjin <dev@peercat.cn>
 * RailEGo is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * RailEGo is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
 */

export interface BaseResponse {
  cookies: string;
}

export interface BypassStationResponse extends BaseResponse {
  stations: BypassStation[];
}

export interface BypassStation {
  arriveTime: string;
  countryCode: string;
  countryName: string;
  endStationName: string;
  isChina: boolean;
  isEnabled: boolean;
  serviceType: string;
  startStationName: string;
  startTime: string;
  stationName: string;
  stationNumber: string;
  stationTrainCode: string;
  stopOverTime: string;
  trainClassName: string;
}

export interface CheckLoginVerifyResponse extends BaseResponse {
  loginCheckCode: string;
  resultCode: number;
  resultMessage: string;
}

export interface GetMessageCodeResponse extends BaseResponse {
  resultCode: number;
  resultMessage: string;
}

export interface NewAppTokenResponse extends BaseResponse {
  appToken?: string;
  resultMessage: string;
  resultCode: number;
  newAppToken: string;
}

export interface QueryOrderResponse extends BaseResponse {
  OrderDTODataList: any[];
  orderTotalNumber: string;
  showCateringButton: boolean;
}

export interface ScheduleResponse extends BaseResponse {
  stationMap: object;
  schedules: Schedule[];
}

export interface Schedule {
  id: number;
  trainCode: string;
  fromStationCode: string;
  fromStationName: string;
  toStationCode: string;
  toStationName: string;
  timeDeparture: string;
  timeArrival: string;
  duration: string;
  Classes: {
    special: string;
    first: string;
    second: string;
    softSleep: string;
    hardSleep: string;
    hardSeat: string;
    noSeat: string;
  }
  TrainType: {
    revival: boolean;
    muteCabin: boolean;
    smart: boolean;
  }
}

export interface TicketPriceResponse extends BaseResponse {
  // 商务座 对应代码为：P
  special?: string;

  // 一等座 对应代码为：M
  first?: string;

  // 二等座 对应代码为：O
  second?: string;

  // 软卧 对应代码为：A4
  softSleep?: string;

  // 硬卧 对应代码为：A3
  hardSleep?: string;

  // 软座 无代码，该类型可能已被取缔
  softSeat?: string;

  // 硬座 对应代码为：A1
  hardSeat?: string;

  // 无座 对应代码为：WZ
  noSeat?: string;
}

export interface UserConfResponse extends BaseResponse {
  isStudentDate: boolean;
  isMessagePassCode: boolean; // != "N"
  bornDate: string;
  isPhoneCheck: boolean; // == "Y"
  eiEmail: string;
  studentDate: string[];
  isUamLogin: boolean; // == "Y"
  isLoginPassCode: boolean; // == "Y"
  username: string;
  isSweepLogin: boolean; // == "Y"
  queryUrl: string;
  psrQrCodeResult: boolean; // != "N" 身份核验
  now: number;
  name: string;
  loginUrl: string;
  stuControl: number;
  isLogin: boolean; // == "Y"
  isOlympicLogin: boolean; // != "N"
  otherControl: number;
}

export interface PossibleTrainResponse extends BaseResponse {
  trains: {
    date: string;
    fromStation: string;
    stationTrainCode: string;
    toStation: string;
    totalNum: string;
    trainNum: string;
  }
}

export interface BannerImageResponse {
  banners: BannerItem[];
}

export interface BannerItem {
  target: string;
  src?: string;
  url: string;
}

export interface NewsItem {
  title: string;
  src: string;
  date: string;
}

export interface NewsResponse {
  news: NewsItem[];
}

export interface AgentSell {
  bureauCode: string;
  stationTelecode: string;
  belongStation: string;
  province: string;
  cityCode: string;
  city: string;
  county: string;
  windows_quantity: string;
  agencyName: string;
  address: string;
  addressEncode: string;
  phoneNumber: string;
  startTimeAm: string;
  stopTimeAm: string;
  startTimePm: string;
  stpTimePm: string;
}

export interface AgentSellResponse {
  agents: AgentSell[];
}

export interface SaleTime {
  bureauCode: string;
  stationName: string;
  stationTelecode: string;
  saleTime: string;
  startDate: string;
  stopDate: string;
  operateTime: string;
}

export interface AllSaleTimeResponse {
  saleTimes: SaleTime[];
}

export interface Passenger {
  name: string; // passenger_name
  sex: string; // sex_name
  birthday: string; // born_date
  countryCode: string; // 国家代码 country_code
  idType: string; // 证件类型 passenger_id_type_name
  idNumber: string; // 证件号 passenger_id_no
  type: string; // 成人 passenger_type_name
  mobileNumber: string; // mobile_no
  phoneNumber: string; // phone_no
}

export interface Province {
  chineseName: string;
  allPin: string;
  simplePin: string;
  stationTelecode: string;
}

export interface AllProvinceResponse {
  provinces: Province[];
}

export interface TicketCheckResponse extends BaseResponse {
  result: boolean; // =="Y"
  trainPlatform: string; // 检票口1A1B
}

export interface SearchItem {
  word: string;
  type: string;
  districtname: string;
  url: string;
  params: SearchTrainParam | SearchTimeCheckParam | SearchLeftTicketParam | SearchStartSellParam | null;
  gotoType: number;
  image: string;
  imageUrl: string;
  need_login: boolean;
  extend: string | null;
  activity: string | null;
  more: string | null;
  name: string | null;
}

export interface SearchTrainParam { // type==001
  date: string;
  station_train_code: string;
  train_no: string;
  total_num: string;
  from_station: string;
  to_station: string;
}

export interface SearchTimeCheckParam { // type==003
  station_name: string;
  station_train_code: string;
  flag: string;
  station_code: string;
}

export interface SearchLeftTicketParam { // type==006
  date: string;
  from_station_name: string;
  to_station_code: string;
  to_station_name: string;
  from_station_code: string;
  purpose_codes: string;
}

export interface SearchStartSellParam { // type==004
  station_name: string;
  station_code: string;
  sale_time: string;
}

export interface TrainInfoData {
  head: TrainInfoHead;
  other: TrainInfo[];
}

export interface TrainInfoHead {
  arrive_day_str: string;
  station_name: string;
  train_class_name: string;
  is_start: string;
  service_type: string;
  end_station_name: string;
  arrive_time: string;
  start_station_name: string;
  station_train_code: string;
  arrive_day_diff: string;
  start_time: string;
  station_no: string;
  wz_num: string;
  running_time: string;
}

export interface TrainInfo {
  arrive_day_str: string;
  arrive_time: string;
  station_train_code: string;
  station_name: string;
  arrive_day_diff: string;
  OT: [],
  start_time: string;
  wz_num: string;
  station_no: string;
  running_time: string;
}